#region Copyright RenGuiYou. All rights reserved.
//=====================================================
// PandoraFrameWork
// Author:      RenGuiyou
// Feedback: 	mailto:750539605@qq.com
//=====================================================
#endregion
using System.Collections.Generic;
using System.IO;
using Pandora;
using UnityEditor;
using Object = UnityEngine.Object;

namespace PandoraEditor
{
    public class PdrFindHelper : PdrFindBase
    {
        #region Property Path
        private static readonly UISetting m_UISetting = UserSetting.UISetting;
        private const string AssetsRootPath = "Assets";
        public static readonly string UIPanelPath = m_UISetting.path_panel;
        private static readonly string SourceAtlasPath = m_UISetting.path_atlas;
        private static readonly string TargetAtlasPath = m_UISetting.path_tp;
        private static readonly string ArtPath = m_UISetting.path_art;
        private static readonly string[] BanSpritePath = m_UISetting.banSpriteArray();
        private static readonly string[] BanTexturePath = m_UISetting.banTextureArray();
        #endregion

        #region GetAssets
        
        /// <summary>
        /// 获取所有Sprite
        /// </summary>
        public static List<string> GetSourceSprites()
        {
            return GetSourceSprites(SourceAtlasPath, BanSpritePath);
        }

        /// <summary>
        /// 获取所有预制
        /// </summary>
        /// <returns></returns>
        public static List<string> GetAllPrefabs()
        {
            return GetPrefabs(AssetsRootPath);
        }
        
        /// <summary>
        /// 获取所有UI预制
        /// </summary>
        public static List<string> GetUIPrefabs()
        {
            return GetPrefabs(UIPanelPath);
        }

        /// <summary>
        /// 获取所有Texture
        /// </summary>
        public static List<string> GetAllTextures()
        {
            return GetTextureImporters(AssetsRootPath, BanTexturePath);
        }

        /// <summary>
        /// 获取Art下所有贴图Importer
        /// </summary>
        public static List<string> GetArtTextures()
        {
            return GetTextureImporters(ArtPath);
        }

        /// <summary>
        /// 获取Atlas下所有贴图Importer
        /// </summary>
        public static List<string> GetAtlasTextures()
        {
            return GetTextureImporters(TargetAtlasPath);
        }

        /// <summary>
        /// 获取所有FBX模型
        /// </summary>
        public static List<string> GetFbxModels()
        {
            return GetFbxImporters(ArtPath);
        }
        #endregion

        #region Defend

        public static string[] GetDependPaths(Object go)
        {
            string sourcePath = AssetDatabase.GetAssetPath(go);
            return AssetDatabase.GetDependencies(sourcePath);
        }
        #endregion
    }
}
